using Greet;
using Grpc.Core;
using Grpc.Net.Client;
using System;
using System.Threading.Tasks;

using var channel = GrpcChannel.ForAddress("https://localhost:5001");
var client = new Greeter.GreeterClient(channel);

await UnaryCallExample(client);
Console.ReadKey();

static async Task UnaryCallExample(Greeter.GreeterClient client)
{
    // 'grpc-internal-encoding-request' is a special metadata value that tells
    // the client to compress the request.
    // This metadata is only used in the client is not sent as a header to the server.
    var metadata = new Metadata();
    metadata.Add("grpc-internal-encoding-request", "gzip");

    var reply = await client.SayHelloAsync(new HelloRequest { Name = "GreeterClient" }, headers: metadata);
    Console.WriteLine("Greeting: " + reply.Message);
}
